#include <stdio.h>
#include <stdint.h>

#include "sm4.h"
// int SM4_set_key(const uint8_t *key, SM4_KEY *ks);
// void SM4_encrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks);
// void SM4_decrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks);

void print_arr(uint8_t *s, int s_size)
{
    for (size_t i = 0; i < s_size; i++)
    {
        printf("%02X ", s[i]);
    }
}

int main(int argc, char const *argv[])
{
    uint8_t cleartext[16] = {
        0x11, 0x22, 0x44, 0x44, 0x55, 0x66, 0x77, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    };
    uint8_t key[16] = {
        0x11, 0x22, 0x44, 0x44, 0x55, 0x66, 0x77, 0x88, 0x11, 0x22, 0x44, 0x44, 0x55, 0x66, 0x77, 0x88,
    };
    uint8_t out[16] = {0};
    uint8_t temp[16] = {0};

    printf("cleartext: ");
    print_arr(cleartext, 16);
    printf("\n");

    printf("key: ");
    print_arr(key, 16);
    printf("\n\n");

    SM4_KEY ks;
    SM4_set_key(key, &ks);

    SM4_encrypt(cleartext, out, &ks);

    printf("encrypt: ");
    print_arr(out, 16);
    printf("\n");

    SM4_decrypt(out, temp, &ks);

    printf("decrypt: ");
    print_arr(temp, 16);
    printf("\n");

    return 0;
}
